﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Seagull.Configuration
{
    public class TaskConfig
    {
        private int _rawDataKeptDays;

        [XmlAttribute("已解析数据本地保留天数")]
        [DisplayName("已解析数据本地保留天数")]
        public int RawDataKeptDays
        {
            get { return _rawDataKeptDays; }
            set
            {
                if(!Config.SupressValidation)
                {
                    if (value < 1)
                    {
                        throw new ArgumentOutOfRangeException("value", value, "已解析数据保留天数过低。");
                    }
                }
                _rawDataKeptDays = value;
            }
        }

        private int _rawLogKeptDays;

        [XmlAttribute("未解析数据本地保留天数")]
        [DisplayName("未解析数据本地保留天数")]
        public int RawLogKeptDays
        {
            get { return _rawLogKeptDays; }
            set
            {
                if(!Config.SupressValidation)
                {
                    if (value < 1)
                    {
                        throw new ArgumentOutOfRangeException("value", value, "未解析数据保留天数过低。");
                    }
                }
                _rawLogKeptDays = value;
            }
        }

        [XmlAttribute("是否压缩备份未解析数据")]
        [DisplayName("是否压缩备份未解析数据")]
        public bool IsRawLogBackuped { get; set; }

        [XmlAttribute("每日例行报警时间")]
        [Browsable(false)]
        public string DailyTimeToSendNewDayAlertString
        {
            get { return DailyTimeToSendNewDayAlert.ToString("hh\\:mm"); }
            set { DailyTimeToSendNewDayAlert = TimeSpan.Parse(value); }
        }

        [XmlIgnore]
        [DisplayName("每日例行报警时间")]
        public TimeSpan DailyTimeToSendNewDayAlert { get; set; }

        [XmlAttribute("清空移动硬盘倒计时秒")]
        [DisplayName("清空移动硬盘倒计时秒")]
        public int CleanUpRemovableDiskCountDownSeconds { get; set; }

        [XmlAttribute("定时重启周期_天")]
        [DisplayName("定时重启周期_天")]
        public int AutoRestartIntervalDays { get; set; }
    }
}
